package com.qidian.mes.qc.controller;

import com.qidian.mes.pojo.TemplateProduct;
import com.qidian.mes.qc.service.TemplateProductService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/templateProduct")
public class TemplateProductController {

    @Autowired
    private TemplateProductService templateProductService;

    //通过外键id查找
    @GetMapping("/get")
    public MESResult get(Long templateId) {
        System.out.println("==========================="+templateId);
        return templateProductService.queryById(templateId);
    }
    //通过id查找
    @GetMapping("/gets")
    public MESResult selectId(Long recordId) {
        System.out.println("==========================="+recordId);
        return templateProductService.selectId(recordId);
    }


    //新增
    @PostMapping("/save")
    public MESResult save(@RequestBody TemplateProduct templateProduct) {
        return templateProductService.save(templateProduct);
    }
    //编辑
    @PutMapping("/update")
    public MESResult update(@RequestBody TemplateProduct templateProduct){
        return templateProductService.update(templateProduct);
    }

    @DeleteMapping("/{recordId}")
    public MESResult deleteById(@PathVariable Long recordId) {
        return templateProductService.deleteByTemplateProductId(recordId);
    }
   @DeleteMapping("/deletes")
   public MESResult deletesByTemplateProductId(Long[] recordId) {
       return templateProductService.deletesByTemplateProductId(recordId);

    }
}
